<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图书管理系统</title>
    <link rel="stylesheet" href="styles/main.css">
</head>

<body>
    <div id="loading" class="loading"></div>

    <!-- 登录页面 -->
    <div id="login-page" class="login-page">
        <div class="login-container">
            <div class="login-header">
                <h2>图书管理系统</h2>
                <p>欢迎使用图书管理系统，请登录</p>
            </div>
            <form id="login-form" class="login-form">
                <div class="form-group">
                    <label for="login-email">邮箱</label>
                    <input type="email" id="login-email" required>
                </div>
                <div class="form-group">
                    <label for="login-password">密码</label>
                    <input type="password" id="login-password" required>
                    <a href="#" id="forgot-password" class="forgot-password-link">忘记密码？</a>
                </div>
                <div class="button-group">
                    <button type="submit" class="button-primary login-button">登录</button>
                    <button type="button" onclick="showRegisterForm()"
                        class="button-secondary register-button">注册账号</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 主应用界面 -->
    <div id="app" style="display: none;">
        <header>
            <h1>图书管理系统</h1>
            <nav>
                <ul>
                    <li><a href="#" id="users-link">用户管理</a></li>
                    <li><a href="#" id="books-link">图书管理</a></li>
                    <li><a href="#" id="borrowing-link">借阅管理</a></li>
                    <li><a href="#" id="logout" class="logout-link">退出登录</a></li>
                </ul>
            </nav>
        </header>

        <main>
            <div id="books-section" class="section">
                <h2>图书管理</h2>
                <div class="controls">
                    <button id="add-book">添加新书</button>
                    <input type="search" id="search-book" placeholder="搜索图书...">
                    <button id="export-books" class="button-secondary">导出数据</button>
                </div>
                <table id="books-table">
                    <thead>
                        <tr>
                            <th data-field="isbn">ISBN</th>
                            <th data-field="title">书名</th>
                            <th data-field="author">作者</th>
                            <th>出版社</th>
                            <th data-field="stock">库存</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
                <div class="pagination">
                    <button id="prev-page" class="button-secondary">&laquo; 上一页</button>
                    <span id="page-info">第 1 页</span>
                    <button id="next-page" class="button-secondary">下一页 &raquo;</button>
                </div>
            </div>

            <div id="users-section" class="section" style="display: none;">
                <h2>用户管理</h2>
                <div class="controls">
                    <button id="add-user">添加用户</button>
                    <input type="search" id="search-user" placeholder="搜索用户...">
                    <button id="export-users" class="button-secondary">导出数据</button>
                </div>
                <table id="users-table">
                    <thead>
                        <tr>
                            <th data-field="id">ID</th>
                            <th data-field="name">姓名</th>
                            <th data-field="email">邮箱</th>
                            <th>电话</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
                <div class="pagination">
                    <button id="prev-page-users" class="button-secondary">&laquo; 上一页</button>
                    <span id="page-info-users">第 1 页</span>
                    <button id="next-page-users" class="button-secondary">下一页 &raquo;</button>
                </div>
            </div>

            <div id="borrowing-section" class="section" style="display: none;">
                <h2>借阅管理</h2>
                <div class="stats-panel">
                    <div class="stat-card">
                        <h3>当前借出</h3>
                        <p id="current-borrowed">0</p>
                    </div>
                    <div class="stat-card">
                        <h3>即将到期</h3>
                        <p id="soon-expire">0</p>
                    </div>
                    <div class="stat-card">
                        <h3>已逾期</h3>
                        <p id="overdue">0</p>
                    </div>
                </div>
                <div class="controls">
                    <button id="new-borrowing">新增借阅</button>
                    <input type="search" id="search-borrowing" placeholder="搜索借阅记录...">
                    <button id="export-borrowings" class="button-secondary">导出数据</button>
                </div>
                <table id="borrowing-table">
                    <thead>
                        <tr>
                            <th data-field="id">ID</th>
                            <th>书名</th>
                            <th>借阅人</th>
                            <th data-field="borrow_date">借阅日期</th>
                            <th data-field="return_date">应还日期</th>
                            <th data-field="status">状态</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
                <div class="pagination">
                    <button id="prev-page-borrowings" class="button-secondary">&laquo; 上一页</button>
                    <span id="page-info-borrowings">第 1 / 4 页</span>
                    <button id="next-page-borrowings" class="button-secondary">下一页 &raquo;</button>
                </div>
            </div>
        </main>

        <!-- 添加模态框 -->
        <div id="modal" class="modal">
            <div class="modal-content">
                <span class="close">&times;</span>
                <div id="modal-body"></div>
            </div>
        </div>
    </div>

    <!-- 注册模态框 -->
    <div id="register-modal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h3>用户注册</h3>
            </div>
            <form id="register-form">
                <div class="form-group">
                    <label for="register-name">姓名</label>
                    <input type="text" id="register-name" required>
                </div>
                <div class="form-group">
                    <label for="register-email">邮箱</label>
                    <input type="email" id="register-email" required>
                </div>
                <div class="form-group">
                    <label for="register-phone">手机号</label>
                    <input type="tel" id="register-phone" pattern="[0-9]{11}" placeholder="请输入11位手机号">
                </div>
                <div class="form-group">
                    <label for="register-password">密码</label>
                    <input type="password" id="register-password" required placeholder="请输入6-20位密码">
                    <span class="password-strength"></span>
                </div>
                <div class="form-group">
                    <label for="register-confirm-password">确认密码</label>
                    <input type="password" id="register-confirm-password" required placeholder="请再次输入密码">
                </div>
                <div class="button-group">
                    <button type="submit" class="button-success">注册</button>
                    <button type="button" onclick="cancelRegister()" class="button-danger">取消</button>
                </div>
                <div class="form-footer">
                    <p>已有账号？<a href="#" onclick="closeModal()">返回登录</a></p>
                </div>
            </form>
        </div>
    </div>

    <!-- 忘记密码模态框 -->
    <div id="forgot-password-modal" class="modal">
        <div class="modal-content">
            <h3>重置密码</h3>
            <form id="forgot-password-form">
                <div class="form-group">
                    <label for="reset-email">邮箱</label>
                    <input type="email" id="reset-email" required>
                </div>
                <div class="form-group">
                    <label for="reset-phone">手机号</label>
                    <input type="tel" id="reset-phone" pattern="[0-9]{11}" required>
                </div>
                <div class="form-group">
                    <label for="reset-password">新密码</label>
                    <input type="password" id="reset-password" required>
                </div>
                <div class="form-group">
                    <label for="reset-confirm-password">确认新密码</label>
                    <input type="password" id="reset-confirm-password" required>
                </div>
                <div class="button-group">
                    <button type="submit" class="button-success">重置密码</button>
                    <button type="button" onclick="cancelResetPassword()" class="button-danger">取消</button>
                </div>
            </form>
        </div>
    </div>

    <script src="scripts/main.js"></script>
</body>

</html>